import {request, handleFetchResultNotification, REQUEST_TYPE} from '../utils';
import {formatMessage} from './intl';
import stringify from 'Shared/utils/stringify';
const baseUrl = '/parts/api/v1';
const afterBaseUrl = '/afterSales/api/v1';
const salesBaseUrl = '/sales/api/v1';

const getListDesc = formatMessage({
    id: 'api.message.getListDesc',
    defaultMessage: '工作台'
});
const getNoticeDataDesc = formatMessage({
    id: 'api.message.getNoticeDataDesc',
    defaultMessage: '查询通知通告'
});
//初始化
export const getInitData = () => request(`${baseUrl}/ui/dashboard/init`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDesc));
//查询通知通告
export const getNoticeData = () => request(`${baseUrl}/dashboards/forNotice`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, getNoticeDataDesc));
//查询保修结算通知
export const getClaimSettlementData = () => request(`${afterBaseUrl}/dashboards/forClaimSettlement`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, getClaimSettlementData));
//待维护工时的备件
export const getWorkItemData = () => request(`${afterBaseUrl}/dashboards/forWorkItem`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//查询扣补款
export const getExpenseAdjustmentData = () => request(`${afterBaseUrl}/dashboards/forExpenseAdjustment`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//待维护辅料的备件
export const getUserDefinedAssistPartData = () => request(`${afterBaseUrl}/dashboards/forUserDefinedAssistPart`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//待维护当月索赔价的备件
export const getPartServicePriceData = () => request(`${afterBaseUrl}/dashboards/forPartServicePrice`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备件需求计划提报提醒
export const getPartOrderPlanData = () => request(`${baseUrl}/dashboards/forPartOrderPlan`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//Back order 确认提醒
export const getPartBackOrderData = () => request(`${baseUrl}/dashboards/forPartBackOrder`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//导入经销存数据提醒
export const getPartStockData = () => request(`${baseUrl}/dashboards/forPartStock`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//查询待审核预申请结算
export const getClaimApplyData = () => request(`${afterBaseUrl}/dashboards/forClaimApply`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//整车滚动计划未提报通知
export const getSalePlanOrderSubmit = () => request(`${salesBaseUrl}/dashboards/forSalePlanOrder/submit`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//整车滚动计划未审核通知
export const getSalePlanOrderApprove = () => request(`${salesBaseUrl}/dashboards/forSalePlanOrder/approve`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备件需求计划驳回提醒
export const getPartOrderPlanReject = () => request(`${baseUrl}/dashboards/forPartOrderPlan/reject`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备件需求计划审核提醒
export const getPartOrderPlanApprove = () => request(`${baseUrl}/dashboards/forPartOrderPlan/approve`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备件销售订单驳回提醒
export const getPartSaleOrderReject = () => request(`${baseUrl}/dashboards/forPartSaleOrder/reject`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备件销售订单审核提醒
export const getPartSaleOrderApprove = () => request(`${baseUrl}/dashboards/forPartSaleOrder/approve`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//PI确认提醒
export const getPartOrderPIConfirm = () => request(`${baseUrl}/dashboards/forPartOrderPI/confirm`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//PI付款提醒
export const getPartOrderPIPay = () => request(`${baseUrl}/dashboards/forPartOrderPI/pay`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//PI生成提醒
export const getPartSaleOrderCreate = () => request(`${baseUrl}/dashboards/forPartSaleOrder/create`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备货需求生成提醒
export const getPartOrderPICreate = () => request(`${baseUrl}/dashboards/forPartOrderPI/create`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备货需求上传SAP提醒
export const getStockRequirementCreate = () => request(`${baseUrl}/dashboards/forStockRequirement/upload`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//查询PI形式发票
export const getSaleProformaInvoice = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${salesBaseUrl}/dashboards/forSaleProformaInvoice?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
};
//销售订单
export const getSaleOrder = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${salesBaseUrl}/dashboards/forSaleOrder?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
};
//查询销售确认书
export const getSaleConfirmation = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${salesBaseUrl}/dashboards/forSaleConfirmation?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
};
//备件索赔单驳回提醒
export const getPartClaimReject = () => request(`${baseUrl}/dashboards/forPartClaim/reject`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备件索赔判定书确认提醒
export const getPartClaimDecisionConfirm = () => request(`${baseUrl}/dashboards/forPartClaimDecision/confirm`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备件索赔发票确认提醒
export const getPartClaimCacuConfirm = () => request(`${baseUrl}/dashboards/forPartClaimCacu/confirm`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//备件索赔单审核提醒
export const getPartClaimApprove = () => request(`${baseUrl}/dashboards/forPartClaim/approve`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//箱单排柜提醒
export const getPackingListCabinetApply = () => request(`${baseUrl}/dashboards/forPackingListCabinetApply`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//货运委托书生成提醒
export const getPartShipOrderCreate = () => request(`${baseUrl}/dashboards/forPartShipOrder/create`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//新增汇率提醒
export const getExchangeRate = () => request(`${baseUrl}/dashboards/forExchangeRate`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//工作日历维护提醒
export const getWorkingDay = () => request(`${baseUrl}/dashboards/forWorkingDay`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
//订单签收提醒
export const getPartShipmentReceipt = () => request(`${baseUrl}/dashboards/forPartShipment/receipt`, null, null)
    .then(handleFetchResultNotification(REQUEST_TYPE.query, null));
